This application is based on applications Nos. 9-219548 and 9-219555 filed in Japan, the content of which is incorporated hereinto by reference.
1. Field of the Invention
The present invention relates to an image processor, and in particular to an image processor which encodes image data.
2. Description of Prior Art
In the field of image processing, block truncation coding is used for compressing image data, and image data divided into blocks are compressed to average information and gradation width information for a block and code information for each pixel in the block. Because the compression ratio of block truncation coding is lower than other encoding techniques, secondary encoding is further performed in order to reduce the memory capacity.
In one of secondary encoding techniques, after image data are compressed with block truncation coding, attribute is decided based on the code data, and the secondary encoding is performed according to the attribute. In another technique, after the attribute of character attribute and non-character attribute is decided on image data, the data of character attribute are subjected to bi-level encoding such as run length or Huffman encoding, and the data of non-character attribute are subjected to multi-level encoding such as JPEG. Thus, data can be encoded at a high compression ratio while keeping image quality at character edges.
However, the above-mentioned techniques that combine block truncation coding with secondary encoding are liable to deteriorate image quality obtained by encoding. When a character image is read with an input apparatus such as a scanner, an edge with a sharp gradient in the character image is read as an edge with a rather gentle gradient owing to the reading precision of the input apparatus. Therefore, though the image data can be encoded at a higher compression ratio, noises occur at edges when the encoded data are decoded, and this deteriorates image quality.
Further, an image of characters in a document is bi-level image inherently. If brightness data of such image is encoded as multi-level data by using block truncation coding and secondary encoding, efficiency is low and compression ratio is low.
An encoder may compress image data mixed with character attribute and non-character attribute with bi-level encoding for character attribute and with multi-level encoding for non-character attribute. In this encoder, conventional bi-level encoding is used for character image, while multi-level encoding is used for non-character attribute by using human visible redundancy which allows to delete unnecessary high frequency components. Then, a high compression ratio can be achieved while keeping high resolution and high frequency components of character image. However, this technique needs a multi-level encoding circuit of JPEG (orthogonal transform, quantization and Huffman encoding) and a bi-level encoding circuit such as run length encoder, and the circuit structure therefor becomes complicated. Bi-level encoding and multi-level encoding have properties different from each other, and code data of different format are stored. Then, it is very difficult to edit or process image data (e.g. rotation, enlargement and reduction) for the code data of different formats. Then, in order to edit or process image data, it is necessary for the encoded data to be decoded to the original image data of large capacity (one byte per pixel), or a large capacity of image data have to be controlled.
In an encoding technique, for a block of image data having character attribute, the image data in the block are binarized to 0 (black) or 255 (white), and block truncation coding is performed thereafter. Further, when a block has character attribute, mode information is encoded to designate all black, all white, or mixture of black and white. For data of mixture of black and white, code information in the block truncation coding data is encoded. If the encoding is performed for character attribute to store only one bit for each pixel of the binarized code data, a high coding ratio is realized by storing only two bytes of code information (00 and 11) for each pixel. However, in this technique, a character image is binarized to 0 and 255, a density difference appears at a boundary between a non-character block and a character block, and an image obtained by decoding becomes ugly.
In one encoding technique, for a block of character attribute, character information and character background information are calculated for the block, and each pixel is replaced with one of them. Then, block truncation coding is performed on the replaced data. Further, the character information, the character background information, and mode information to designate all character, all character background, or mixture of character and character background are stored. Further, for mixture of character and character background, the code data of block truncation coding are stored and encoded. However, in this technique, before block truncation coding, a large amount of image data have to be subjected to the attribute decision and the character conversion. Then, many buffer memories have to be used, and a circuit structure therefor becomes complicated.
An object of the present invention is to provide an image processor which has improved coding efficiency for character block in an image mixed with character areas and non-character (photograph or the like) areas and which does not generate noises at character edges or the like when the code data are decoded.
Another object of the present invention is to provide an image processor which has improved efficiency for character areas in an image mixed with character areas and non-character areas while maintains resolution of character areas with block truncation coding and which does not generate noises at boundaries between areas of character attribute and those of non-character attribute when the code data are decoded.
A further object of the present invention is to provide an image processor which has an encoding circuit with a simple structure.
A still further object of the present invention is to provide an image processor which can edit or process an image by using encoded data.
In one aspect of the present invention, an image processor comprises a decider which decides based on image data of pixels included in a block whether the block has character attribute of non-character attribute, a first encoder which encodes the image data with block truncation coding, and a second encoder which encodes the image data which have been encoded by the first encoder. When the decider decides that the block has character attribute, a binarizer binarizes the image data. Then, the binarized data are encoded by the first and second encoders. On the other hand, when the decider decides that the block has non-character attribute, the image data are encoded by the first and second encoders without binarization by the binarizer.
In a second aspect of the invention, an image processor comprises a decider which decides whether image data of pixels in an area are all character, all ground or mixture of character and ground. The area consists of a plurality of blocks. An encoder encodes the image data in each block differently according to the decision. For example, the attribute of image data for a block is further decided to be character or non-character, and for a block of character attribute, the image data are converted to character or ground level before block truncation coding. In a different way, the decider performs the decision on block truncation coding data. Thus, the compression ratio of image data is improved further.
An advantage of the present invention is that a sharp edge of a character image can be reproduced well even if it is read as an image having a gentle gradient.
Another advantage of the present invention is that a high compression ratio can be attained by using a relatively simple circuit structure.